// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import JSONView from 'vue-json-viewer'
Vue.use(JSONView);

// elementUI 导入
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
// 调用插件
Vue.use(ElementUI);
import '../static/global/global.css'
// import '../static/global/gt.js'

// axios的引入
import * as api from './restful/api'

Vue.prototype.$http = api;

import echarts from 'echarts'
Vue.prototype.$echarts = echarts ;

import * as myTool from './myTool/myTool'
Vue.prototype.$myTool = myTool;
// store的引入
import store from '../src/store'


let getInfoFunc = (getStr, setStr) => {
  var objInfo = localStorage.getItem(getStr);
  if (objInfo) {
    // 用户登录过
    objInfo = JSON.parse(objInfo);
    store.dispatch(setStr, objInfo);
  }
};
// 全局守卫
router.beforeEach((to, from, next) => {
  getInfoFunc("userInfo",'getUserInfo');//用户信息
  getInfoFunc("choicesInfo",'getChoicesInfo');  // 项目所有的CHOICES
  getInfoFunc("apiPreviousInfo",'getApiPreviousInfo'); // 上一次接口列表保存信息

  next();
});
Vue.config.productionTip = false;



/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {App},
  template: '<App/>'
});
